﻿using PostSharp.Aspects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TopUpService.AOP.Aspects
{
    [Serializable]
    class NotNullArgumentAspect : OnMethodBoundaryAspect
    {
        public override void OnEntry(MethodExecutionArgs args)
        {
            var parameters = args.Method.GetParameters();
            var arguments = args.Arguments;
            for(int i = 0; i < arguments.Count; i++)
            {
                if (arguments[i] == null)
                {
                    throw new ArgumentNullException(parameters[i].Name);
                }
            }
        }
    }
}
